<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css"/>
	<script src="${pageContext.request.contextPath}/js/getmd5.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/js/jquery-1.7.2.min.js" type="text/javascript"></script>
	<script language="JavaScript">	
	$(function () {
		H_login = {};
	    H_login.openLogin = function(){
	        $('.open-login').click(function(){
	            $('.login').show();
	        });
	    };
	    H_login.closeLogin = function(){
	        $('.close-login').click(function(){
	            $('.login').hide();
	        });
	    };
	    H_login.run = function () {
	        this.openLogin();
	        this.closeLogin();
	    };
	    H_login.run();
	});
	</script>
	<script type="text/javascript">
		function asubmit() {
			var add = document.getElementById("loginForm");		
			add.action="${pageContext.request.contextPath}/login.action";
			var username = document.getElementById("username");
			var password = document.getElementById("password");
			if(username.value != 0){
				if(password.value !=0 ){
					password.value = hex_md5(password.value);
					add.submit();
				}else{
					alert("请输入密码");
					password.focus();
				}	
			}else{
				alert("请输入用户名");
				username.focus();
			}
		}
		function validate(){		
			<c:if test="${not empty msg }">alert("${msg}");</c:if>
		}
	</script>
  </head>
  
  <body onload="validate()">
	  <div>
	            欢迎
	    ${admin.id},${admin.name}
	    <a href="javascript:void(0);" class="open-login">登录</a>
	   </div>
	   <br/>
	   <br/>
	   <br/>
	   <br/>
	   <br/>
	   <div class="login">
	   <span><a href="javascript:void(0);" class="close-login">关闭</a></span>
	   <form action="#" method="post" id="loginForm">
    		用户名：<input type="text" name="user.username" id="username"/><br />
    		密&nbsp;码：<input type="password" name="user.pwd" id="password" />
    		<s:token/>
    		<input type="button" value="登录" onclick="asubmit()">
    	</form>
    	<a href="${pageContext.request.contextPath}/login/register">立即注册</a>
	   </div> 
  </body>
</html>
